package com.ruoyi.user.controller.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SpffCategories;
import com.ruoyi.system.service.ISpffCategoriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 视频分类Controller
 * 
 * @author xjj
 * @date 2025-09-11
 */
@RestController
@RequestMapping("/userApi/categories")
public class USpffCategoriesController extends BaseController
{
    @Autowired
    private ISpffCategoriesService spffCategoriesService;

    /**
     * 查询视频分类列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SpffCategories spffCategories)
    {
        startPage();
        List<SpffCategories> list = spffCategoriesService.selectSpffCategoriesList(spffCategories);
        return getDataTable(list);
    }

    /**
     * 导出视频分类列表
     */

    @Log(title = "视频分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SpffCategories spffCategories)
    {
        List<SpffCategories> list = spffCategoriesService.selectSpffCategoriesList(spffCategories);
        ExcelUtil<SpffCategories> util = new ExcelUtil<SpffCategories>(SpffCategories.class);
        util.exportExcel(response, list, "视频分类数据");
    }

    /**
     * 获取视频分类详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(spffCategoriesService.selectSpffCategoriesById(id));
    }

    /**
     * 新增视频分类
     */
    @Log(title = "视频分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpffCategories spffCategories)
    {
        return toAjax(spffCategoriesService.insertSpffCategories(spffCategories));
    }


}
